# -*- coding: utf-8 -*- # 
import wx
from SortedList import SortedList

class SortedListPanel(wx.Panel, SortedList):
	def __init__(self, parent):
		wx.Panel.__init__(self, parent, -1)
		SortedList.__init__(self, parent)
	
		self.load()

	
	def init(self):

		box = wx.BoxSizer(wx.VERTICAL)
	

		self.list = self.createlist( [
			(u'',	 0,	 'right'),
			(u'序号',	 70,	 'right'),
			(u'名称',	 120,	'left'),
			(u'描述',	 250,	'left'),
			]
		)
		box.Add(self.list, 1, wx.EXPAND|wx.LEFT|wx.RIGHT, 2)

		self.SetSizer(box)
		self.SetAutoLayout(True)

	def initdata(self):
		datas = {}
		for i in range(100):
			datas[i] = ('', i, 'name%02d' % i, 'desc%02d' % i)
		return datas
	
	def load(self):
		number = self.loaddata()
		self.SortListItems(col=1)

class TestApp(wx.App):
	def OnInit(self):
		self.frame = wx.Frame(None, -1)
		self.panel = SortedListPanel(self.frame)
		self.SetTopWindow(self.frame)
		self.frame.Show()
		return True
	

app = TestApp(0)
app.MainLoop()